const request = require('../../utils/request.js');

Page({
  data: {
    user_data: {},
  },
  onLoad(){
    this.getUserData();
  },

  onShow(){
    this.getUserData();
  },
  // 跳转到历史订单页面
  goToOrderHistory() {
    wx.switchTab({
      url: '/pages/order/order',
    });
  },

  getUserData(){
    request.post('/index/UserData')
    .then(res=>{
      this.setData({
        user_data: res.data,
      })
      console.log(this.user_data);
    })
  },

  // 跳转到修改个人信息页面
  goToEditPage() {
    wx.navigateTo({
      url: '/pages/user/profile/profile',
    });
  },

  logout(){
    // wx.getStorageSync('token');
    wx.removeStorageSync('token')
    wx.reLaunch({ url: '/pages/login/login' });
  }

  
});
